package com.uuah.server.config.spring.factories;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;

import com.uuah.api.lifecycle.Initialisable;
import com.uuah.exception.lifecycle.InitialisationException;
import com.uuah.server.endpoint.EndpointURIEndpointBuilder;

/**
 * Abstract spring FactoryBean used to creating endpoints via spring.
 */
public abstract class AbstractEndpointFactoryBean extends
		EndpointURIEndpointBuilder implements FactoryBean, Initialisable {

	protected transient final Logger logger = LoggerFactory.getLogger(getClass());

	public AbstractEndpointFactoryBean() {
		super();
	}

	public Object getObject() throws Exception {
		return doGetObject();
	}

	public boolean isSingleton() {
		return true;
	}

	public void initialise() throws InitialisationException {
		// subclasses may override this method
	}

	protected abstract Object doGetObject() throws Exception;

}
